function sch = getTablesSchema(DBobj, cat, tbl)
  % Get the schema name sch (from catalog cat in DBobj) to which table tbl belongs
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: N/A

    if isconnection(DBobj)
        for sch = schemas(DBobj)
            try
                ts = tables(DBobj, cat, sch);
                if ismember(tbl, ts)
                    return
                end
            catch
            end
        end
    else
        sch = ['Sorry, connection to database ' DBobj.Instance ' lost.  Attempt to determine table '...
               tbl '''s schema failed.']; 
    end